package park.gz.com.parkingfee.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.xutils.db.annotation.Column;
import org.xutils.db.annotation.Table;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017-03-20.
 */
@Table(name="UserBean")
public class UserBean {
    @Column(name="id")
    private String id;
    @Column(name="login")
    private String login;
    @Column(name="password")
    private String password;
    @Column(name="usertype")
    private String usertype;
    @Column(name="status")
    private String status;
    @Column(name="created_at")
    private String created_at;

    public String getUpdated_at() {
        return updated_at;
    }

    public void setUpdated_at(String updated_at) {
        this.updated_at = updated_at;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsertype() {
        return usertype;
    }

    public void setUsertype(String usertype) {
        this.usertype = usertype;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCreated_at() {
        return created_at;
    }

    public void setCreated_at(String created_at) {
        this.created_at = created_at;
    }
    @Column(name="updated_at")
    private String updated_at;

    public static List<UserBean> parse(JSONArray jsonArray) throws JSONException{
        List<UserBean> userlist = new ArrayList<UserBean>();
        for (int i = 0;i<jsonArray.length();i++){
            JSONObject jsonObject = new JSONObject(jsonArray.get(i).toString());
            UserBean userBean = new UserBean();
            userBean.id = jsonObject.getString("id");
            userBean.login = jsonObject.getString("login");
            userBean.password = jsonObject.getString("password");
            userBean.usertype = jsonObject.getString("user_type");
            userBean.status = jsonObject.getString("status");
            userBean.created_at = jsonObject.getString("created_at");
            userBean.updated_at = jsonObject.getString("updated_at");
            userlist.add(userBean);
        }
        return  userlist;
    }
}
